import 'package:flutter/material.dart';
import 'package:flutter_basic_learning/views/BottomNavigationBar/HomePage.dart';
import 'package:flutter_basic_learning/views/BottomNavigationBar/HotPage.dart';
import 'package:flutter_basic_learning/views/FlutterRoute/FlutterRoutePage.dart';
import 'package:flutter_basic_learning/views/FlutterRoute/RoutePageOne.dart';
import 'package:flutter_basic_learning/views/FlutterRoute/RoutePageTwo.dart';
import 'package:flutter_basic_learning/views/LoginPage.dart';
import 'package:flutter_basic_learning/views/PageViewPage.dart';
import 'package:flutter_basic_learning/views/getx/GetRouterPage.dart';
import 'package:flutter_basic_learning/views/getx/GetXStateManagerPage.dart';
import 'package:flutter_basic_learning/views/getx/MiddleWarePage.dart';
import 'package:flutter_basic_learning/views/getx/get_view/GetViewBinding.dart';
import 'package:flutter_basic_learning/views/getx/get_view/GetViewPageOne.dart';
import 'package:flutter_basic_learning/views/getx/get_view/GetViewPageTwo.dart';
import 'package:flutter_basic_learning/views/getx/getx_binding/AllControllerBinding.dart';
import 'package:flutter_basic_learning/views/getx/getx_binding/GetxBindingPageOne.dart';
import 'package:flutter_basic_learning/views/getx/getx_binding/GetxBindingPageTwo.dart';
import 'package:flutter_basic_learning/views/getx/getx_controller/PageOne.dart';
import 'package:flutter_basic_learning/views/getx/getx_controller/PageTwo.dart';
import 'package:flutter_basic_learning/views/getx/middle_ware/RouteMiddleWare.dart';
import 'package:get/get.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  MyApp({super.key});

  final Map routes = {
    "/": (context, {Object? arguments}) => const FlutterRoutePage(),
    "/pageOne": (context, {Object? arguments}) =>
        RoutePageOne(arguments: arguments),
    "/pageTwo": (context, {Object? arguments}) => const RoutePageTwo(),
  };

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return GetMaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      // home: const GetRouterPage(),
      // home: const BottomSheetPage(),
      // home: const PageViewPage(),
      // home: const TabBarPage(),
      // home: const FlutterRoutePage(),
      // home: const BottomNavigationBarPage(),
      // home: const ListWidget(),
      // home: const HomePage(title: 'HomePage'),
      // home: const ImageWidget(),
      // home: const IconWidget(),
      debugShowCheckedModeBanner: false,
      initialRoute: '/get_view_page_one',
      defaultTransition: Transition.leftToRightWithFade,
      initialBinding: AllControllerBinding(),
      getPages: [
        GetPage(name: '/', page: () => const GetRouterPage()),
        GetPage(name: '/homepage', page: () => const HomePage()),
        GetPage(name: '/login', page: () => const LoginPage()),
        GetPage(name: '/pageView', page: () => const PageViewPage()),
        GetPage(name: '/routeOne', page: () => const RoutePageOne()),
        GetPage(
            name: '/hot',
            page: () => const HotPage(),
            middlewares: [RouteMiddleWare()]),
        GetPage(name: '/middle_ware', page: () => const MiddleWarePage()),
        GetPage(name: '/state_manager', page: () => GetXStateManagerPage()),
        GetPage(name: '/data_share_page_one', page: () => PageOne()),
        GetPage(name: '/data_share_page_two', page: () => PageTwo()),
        GetPage(
            name: '/getx_binding_page_one', page: () => GetxBindingPageOne()),
        GetPage(
            name: '/getx_binding_page_two', page: () => GetxBindingPageTwo()),
        GetPage(
            name: '/get_view_page_one',
            binding: GetViewBinding(),
            page: () => const GetViewPageOne()),
        GetPage(
            name: '/get_view_page_two',
            binding: GetViewBinding(),
            page: () => const GetViewPageTwo()),
      ],
      // initialRoute: "/",
      // routes: routes,//静态路由
      // onGenerateRoute: (RouteSettings settings) {
      //   final pageContentBuilder = routes[settings.name];
      //   final Object? arguments = settings.arguments;
      //
      //   if (pageContentBuilder != null) {
      //     return MaterialPageRoute(builder: (context) {
      //       return pageContentBuilder(context, arguments: arguments);
      //     });
      //   }
      //   return null;
      // }
    );
  }
}
